# encoding=utf-8
from flask_script import Manager
from app.database.connections import app,db
from app.models.models import Cpu

# -----------------------------------
manager = Manager(app)

# {'utilization': 14.2, 'logical_processors': 8, 'speed': 2301.0, 'base_speed': 2301.0, 'processes': 274,
#      'start_machine_time_str': '2020-10-31 11:59:59', 'kernels': 4, 'handles': 116985, 'threads': 3447,
#      'mac_code': 'b89a2a6a20dd'}
@manager.command
def save():
    #'b88a2a6a20dd','Intel',14.2,2301.0,274,3447,116985,'2020-10-31 11:59:59',2301.0,9,4,8
    cpu = Cpu('b88a2a6a20dd','Intel',14.2,2301.0,274,3447,116985,'2020-10-31 11:59:59',2301.0,9,4,8)
    db.session.add(cpu)
    db.session.commit()

@manager.command
def query_cpu():
    cpus = Cpu.query.all()
    for c in cpus:
        print(c)

if __name__ == '__main__':
    manager.run()
